package com.zzx.boot.controller;

import com.zzx.boot.entity.dto.AddCommentDto;
import com.zzx.boot.entity.vo.CommentVo;
import com.zzx.boot.servlet.CommentService;
import com.zzx.boot.utils.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * @author tan
 * @version 1.0
 * @date 2023/7/10 17:00
 */
@Api(tags = "评论模块")
@RestController
@RequestMapping("/comment")
@RequiredArgsConstructor
public class CommentController {

    private final CommentService commentService;

    @ApiOperation(value = "回复评论")
    @PostMapping("/add")
    public R addComment(@Valid  AddCommentDto commentDto){
        return R.success(commentService.addComment(commentDto));
    }

    @ApiOperation(value = "获取文章下的所有评论")
    @PostMapping("/post/{postId}/list/{current}/page")
    public R getCommentPage(@PathVariable("postId")Long postId,@PathVariable("current")Long current){
        return R.success(commentService.getCommentPage(postId,current));
    }


}
